export const popState = {
  created () {
    let id = this.$route.query.id
    let src = this.$route.query.src
    let that = this
    if (window.history && window.history.pushState) {
      $(window).on('popstate', function () {
        if (sessionStorage.getItem('isIframe') === '1') {
          sessionStorage.setItem('isIframe', 0)
          that.clientIframeClose()
          window.history.pushState('forward', null, '')
          return false
        }
        // 判断手机操作系统
        let u = navigator.userAgent
        let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1 // android终端
        let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) // ios终端
        if (isAndroid) {
          window.location.replace('/?#/total?id=' + id + '&src=' + src + '&count=' + localStorage.getItem('count' + id))
        } else if (isiOS) {
          if (sessionStorage.getItem('isTotal') === '1') {
            sessionStorage.setItem('isTotal', 2)
          } else {
            window.location.replace('/?#/total?id=' + id + '&src=' + src + '&count=' + localStorage.getItem('count' + id))
          }
        }
      })
    }
    window.history.pushState('forward', null, '')
  }
}